package com.cpi.basilos.silo.dto;

import java.io.Serializable;
import com.cpi.basilos.unit.dto.UnitDTO;
import com.cs.common.utils.StringUtils;

public class SiloEntryMovementsDTO extends SiloEntryDTO implements Serializable{
	private static final long serialVersionUID = 1L;
	
	private boolean furgKind;
	private String operation;
	private int tank;
	private String cornType;
	private double originAmount;
	
	public boolean isFurgKind() {
		return furgKind;
	}
	public void setFurgKind(boolean furgKind) {
		this.furgKind = furgKind;
	}
	public String getOperation() {
		return operation;
	}
	public void setOperation(String operation) {
		this.operation = operation;
	}
	public int getTank() {
		return tank;
	}
	public void setTank(int tank) {
		this.tank = tank;
	}
	public String getCornType() {
		return cornType;
	}
	public void setCornType(String cornType) {
		this.cornType = cornType;
	}
	public double getOriginAmount() {
		return originAmount;
	}
	public void setOriginAmount(double originAmount) {
		this.originAmount = originAmount;
	}
	
	public boolean equals(Object obj) {
		boolean retValue = false;
		UnitDTO unitDTO = null;
		StringBuffer concat = null;
		if( obj != null ){
			if( obj instanceof SiloEntryMovementsDTO ){
				if( this.getFurg().equals(((SiloEntryMovementsDTO)obj).getFurg()) ){
					retValue = true;
				}
			}else if( obj instanceof UnitDTO ){
				unitDTO = (UnitDTO)obj;
				concat = new StringBuffer(unitDTO.getInitial().length() + 1 + unitDTO.getNumber().length());
				if( concat.append(unitDTO.getInitial()).append(StringUtils.SLASH_CHAR).append(unitDTO.getNumber()).toString().equals(this.getFurg()) ){
					retValue = true;
				}else if( concat.append(unitDTO.getInitial()).append(StringUtils.SPACE_CHAR).append(unitDTO.getNumber()).toString().equals(this.getFurg()) ){
					retValue = true;
				}
			}
		}
		return retValue;
	}
	public String toString() {
		return getFurg();
	}
	public int hashCode() {
		return toString().hashCode();
	}


}
